import React, { forwardRef } from 'react';
import { IconComponentProps } from '@ant-design/icons/lib/components/Icon';
import AntIcon from '@ant-design/icons';

type IconProps = IconComponentProps & {
  name: string;
};

function SvgIcon({ name: type, ...props }: IconProps, ref) {
  return (
    <AntIcon
      ref={ref}
      className='icon-svg'
      component={() => (
        <svg
          width='1em'
          height='1em'
          fill='currentColor'>
          <use href={`#${type}`} />
        </svg>
      )}
      {...props}
    />
  );
}

export const Icon = forwardRef(SvgIcon);
